home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Linux
/
Kubuntu 8.10
/
kubuntu-8.10-desktop-i386.iso
/
casper
/
filesystem.squashfs
/
var
/
lib
/
dpkg
/
info
/
udev.preinst
< prev
next >
Wrap
Text File
|
2008-10-24
|
4KB
|
151 lines
#!/bin/sh -e
# This script can be called in the following ways:
#
# Before the package is installed:
# <new-preinst> install
#
# Before removed package is upgraded:
# <new-preinst> install <old-version>
#
# Before the package is upgraded:
# <new-preinst> upgrade <old-version>
#
#
# If postrm fails during upgrade or fails on failed upgrade:
# <old-preinst> abort-upgrade <new-version>
# Prepare to remove a no-longer used conffile
prep_rm_conffile()
{
CONFFILE="$1"
if [ -e "$CONFFILE" ]; then
md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
if [ "$md5sum" != "$old_md5sum" ]; then
echo "Obsolete conffile $CONFFILE has been modified by you, renaming to .dpkg-bak"
mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
else
mv -f "$CONFFILE" "$CONFFILE".dpkg-obsolete
fi
fi
}
# Prepare to move a conffile without triggering a dpkg question
prep_mv_conffile() {
CONFFILE="$1"
if [ -e "$CONFFILE" ]; then
md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
if [ "$md5sum" = "$old_md5sum" ]; then
mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
else
mv -f "$CONFFILE" "$CONFFILE".dpkg-moving
fi
fi
}
# Prepare to rename the persistent-disk.rules file
prep_mv_persistent_disk_rules()
{
prep_mv_conffile /etc/udev/rules.d/65-persistent-disk.rules \
/etc/udev/rules.d/60-persistent-storage.rules
}
# Prepare to rename the cdrom_id.rules file
prep_mv_cdrom_id_rules()
{
prep_mv_conffile /etc/udev/rules.d/50-cdrom_id.rules \
/etc/udev/rules.d/30-cdrom_id.rules
}
# Prepare to rename the upstream rules files
prep_mv_upstream_rules()
{
prep_mv_conffile /etc/udev/rules.d/00-init.rules \
/etc/udev/rules.d/05-udev-early.rules
prep_mv_conffile /etc/udev/rules.d/65-persistent-input.rules \
/etc/udev/rules.d/60-persistent-input.rules
prep_mv_conffile /etc/udev/rules.d/65-persistent-storage.rules \
/etc/udev/rules.d/60-persistent-storage.rules
prep_mv_conffile /etc/udev/rules.d/65-persistent-storage-tape.rules \
/etc/udev/rules.d/60-persistent-storage-tape.rules
prep_mv_conffile /etc/udev/rules.d/65-persistent-storage-edd.rules \
/etc/udev/rules.d/61-persistent-storage-edd.rules
prep_mv_conffile /etc/udev/rules.d/99-udevmonitor.rules \
/etc/udev/rules.d/95-udev-late.rules
}
# Prepare to remove the iftab.rules file
prep_rm_iftab_rules()
{
prep_rm_conffile /etc/udev/rules.d/25-iftab.rules
}
# Prepare to remove early rules files
prep_rm_early_rules()
{
prep_rm_conffile /etc/udev/rules.d/05-udev-early.rules
}
# Prepare to remove upstream rules files
prep_rm_upstream_rules()
{
prep_rm_conffile /etc/udev/rules.d/50-udev-default.rules
prep_rm_conffile /etc/udev/rules.d/80-drivers.rules
}
# Prepare to remove the finish init script
prep_rm_finish_init()
{
prep_rm_conffile /etc/init.d/finish
}
case "$1" in
install|upgrade)
# Upgrade from dapper
if dpkg --compare-versions "$2" lt "093-0ubuntu1"; then
prep_mv_persistent_disk_rules
fi
# Upgrade within feisty development cycle
if dpkg --compare-versions "$2" lt "108-0ubuntu1"; then
prep_mv_cdrom_id_rules
fi
# Upgrade from feisty
if dpkg --compare-versions "$2" lt "113-0ubuntu16"; then
prep_rm_iftab_rules
# Upgrade from gutsy development version
prep_rm_finish_init
fi
# Upgrade from gutsy
if dpkg --compare-versions "$2" lt "117-6"; then
prep_mv_upstream_rules
prep_rm_early_rules
# Upgrade from hardy development version
prep_rm_upstream_rules
fi
;;
abort-upgrade)
;;
*)
echo "$0 called with unknown argument \`$1'" 1>&2
exit 1
;;
esac
exit 0